package com.study.week1_study;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.io.StringWriter;

/**
 * @author Abner
 * @date 2021/7/7 22:06
 * @email songkd90@163.com
 * @description
 */
public class CommonShowTag extends SimpleTagSupport {

    private String user;

    private String phoneNum;

    private String email;

    StringWriter sw = new StringWriter();

    @Override
    public void doTag() throws JspException, IOException {
        if (user != null) {
            JspWriter out = getJspContext().getOut();
            out.println(user);
        } else {
            getJspBody().invoke(sw);
            getJspContext().getOut().println(sw.toString());
        }

        if (phoneNum != null) {
            JspWriter out = getJspContext().getOut();
            out.println(phoneNum);
        } else {
            getJspBody().invoke(sw);
            getJspContext().getOut().println(sw.toString());
        }

        if (email != null) {
            JspWriter out = getJspContext().getOut();
            out.println(email);
        } else {
            getJspBody().invoke(sw);
            getJspContext().getOut().println(sw.toString());
        }
    }

    public String getUser() {
        return user;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public String getEmail() {
        return email;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public void setEmail(String email) {
        this.email = email;
    }
}
